flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_lib: bool,
flag_bin: Vec<String>,
flag_example: Vec<String>,
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to build benchmarks for
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
All of the trailing arguments are passed to the benchmark binaries generated
for filtering benchmarks and generally providing options configuring how they
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let ops = ops::TestOptions {
no_run: options.flag_no_run,
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
If the --package argument is given, then SPEC is a package id specification
which indicates which package should be built. If it is not given, then the
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-build; args={:?}",
env::args().collect::<Vec<_>>());
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
struct Flags {
flag_list: bool,
flag_verbose: bool,
+ flag_quiet: bool,
arg_command: String,
arg_args: Vec<String>,
}
-V, --version Print version info and exit
--list List installed commands
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
Some common cargo commands are:
build Compile the current project
on this top-level information.
*/
fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(flags.flag_verbose);
+ try!(config.shell().set_verbosity(flags.flag_verbose, flags.flag_quiet));
init_git_transports(config);
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
--manifest-path PATH Path to the manifest to the package to clean
--target TRIPLE Target triple to clean output for (default all)
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
If the --package argument is given, then SPEC is a package id specification
which indicates which package's artifacts should be cleaned out. If it is not
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::<Vec<_>>());
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
flag_no_deps: bool,
flag_open: bool,
flag_verbose: bool,
+ flag_quiet: bool,
flag_package: Option<String>,
}
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to document
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
By default the documentation for the local package and all dependencies is
built. The output is all placed in `target/doc` in rustdoc's usual format.
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
struct Options {
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
-h, --help Print this message
--manifest-path PATH Path to the manifest to fetch dependencies for
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
If a lockfile is available, this command will ensure that all of the git
dependencies and/or registries dependencies are downloaded and locally
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
try!(ops::fetch(&root, config).map_err(|e| {
CliError::from_boxed(e, 101)
struct Options {
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
-h, --help Print this message
--manifest-path PATH Path to the manifest to generate a lockfile for
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::<Vec<_>>());
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
ops::generate_lockfile(&root, config)
flag_url: String,
flag_reference: String,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
Options:
-h, --help Print this message
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let Options { flag_url: url, flag_reference: reference, .. } = options;
let url = try!(url.to_url().map_err(|e| {
flag_host: Option<String>,
arg_token: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
-h, --help Print this message
--host HOST Host to set the token for
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let token = match options.arg_token.clone() {
Some(token) => token,
None => {
#[derive(RustcDecodable)]
struct Options {
flag_verbose: bool,
+ flag_quiet: bool,
flag_bin: bool,
arg_path: String,
flag_name: Option<String>,
--bin Use a binary instead of a library template
--name <name> Set the resulting package name
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::<Vec<_>>());
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let Options { flag_bin, arg_path, flag_name, flag_vcs, .. } = options;
flag_remove: Option<Vec<String>>,
flag_index: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_list: bool,
}
--index INDEX Registry index to modify owners for
--token TOKEN API token to use when authenticating
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
This command will modify the owners for a package on the specified registry (or
default). Note that owners of a package can upload new versions, yank old
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let opts = ops::OwnersOptions {
krate: options.arg_crate,
token: options.flag_token,
#[derive(RustcDecodable)]
struct Options {
flag_verbose: bool,
+ flag_quiet: bool,
flag_manifest_path: Option<String>,
flag_no_verify: bool,
flag_no_metadata: bool,
--no-metadata Ignore warnings about a lack of human-usable metadata
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
ops::package(&root, config,
!options.flag_no_verify,
#[derive(RustcDecodable)]
struct Options {
flag_verbose: bool,
+ flag_quiet: bool,
flag_manifest_path: Option<String>,
arg_spec: Option<String>,
}
-h, --help Print this message
--manifest-path PATH Path to the manifest to the package to clean
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
Given a <spec> argument, print out the fully qualified package id specifier.
This command will generate an error if <spec> is ambiguous as to which package
pub fn execute(options: Options,
config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path.clone()));
let spec = options.arg_spec.as_ref().map(|s| &s[..]);
flag_token: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_no_verify: bool,
}
--no-verify Don't verify package tarball before publish
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let Options {
flag_token: token,
flag_host: host,
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_release: bool,
arg_args: Vec<String>,
}
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to execute
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
If neither `--bin` or `--example` are given, then if the project only has one
bin target it will be run. Otherwise `--bin` specifies the bin target to run,
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
+
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
let (mut examples, mut bins) = (Vec::new(), Vec::new());
flag_target: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
--target TRIPLE Target triple which compiles will be for
--manifest-path PATH Path to the manifest to fetch depednencies for
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
The specified target for the current package (or package specified by SPEC if
provided) will be compiled along with all of its dependencies. The specified
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-rustc; args={:?}",
env::args().collect::<Vec<_>>());
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
struct Options {
flag_host: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
arg_query: String
}
-h, --help Print this message
--host HOST Host of a registry to search in
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let Options {
flag_host: host,
arg_query: query,
flag_test: Vec<String>,
flag_bench: Vec<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_release: bool,
}
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to build tests for
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
All of the trailing arguments are passed to the test binaries generated for
filtering tests and generally providing options configuring how they run. For
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let ops = ops::TestOptions {
no_run: options.flag_no_run,
flag_precise: Option<String>,
flag_manifest_path: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
--precise PRECISE Update a single dependency to exactly PRECISE
--manifest-path PATH Path to the manifest to compile
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
This command requires that a `Cargo.lock` already exists as generated by
`cargo build` or related commands.
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
debug!("executing; cmd=cargo-update; args={:?}", env::args().collect::<Vec<_>>());
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
let spec = options.flag_package.as_ref();
struct Flags {
flag_manifest_path: String,
flag_verbose: bool,
+ flag_quiet: bool,
}
pub const USAGE: &'static str = "
-h, --help Print this message
--manifest-path PATH Path to the manifest to verify
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
";
pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
- config.shell().set_verbose(args.flag_verbose);
+ try!(config.shell().set_verbosity(args.flag_verbose, args.flag_quiet));
let mut contents = String::new();
let file = File::open(&args.flag_manifest_path);
flag_vers: Option<String>,
flag_index: Option<String>,
flag_verbose: bool,
+ flag_quiet: bool,
flag_undo: bool,
}
--index INDEX Registry index to yank from
--token TOKEN API token to use when authenticating
-v, --verbose Use verbose output
+ -q, --quiet No output printed to stdout
The yank command removes a previously pushed crate's version from the server's
index. This command does not delete any data, and the crate will still be
";
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
- config.shell().set_verbose(options.flag_verbose);
+ try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
try!(ops::yank(config,
options.arg_crate,
options.flag_vers,
pub use self::package_id_spec::PackageIdSpec;
pub use self::registry::Registry;
pub use self::resolver::Resolve;
-pub use self::shell::{Shell, MultiShell, ShellConfig};
+pub use self::shell::{Shell, MultiShell, ShellConfig, Verbosity};
pub use self::source::{Source, SourceId, SourceMap, SourceSet, GitReference};
pub use self::summary::Summary;
use term::{Terminal, TerminfoTerminal, color};
use self::AdequateTerminal::{NoColor, Colored};
+use self::Verbosity::{Verbose, Normal, Quiet};
+
+use util::errors::{human, CargoResult};
+
+#[derive(Clone, Copy, PartialEq)]
+pub enum Verbosity {
+ Verbose,
+ Normal,
+ Quiet
+}
#[derive(Clone, Copy)]
pub struct ShellConfig {
pub color: bool,
- pub verbose: bool,
+ pub verbosity: Verbosity,
pub tty: bool
}
pub struct MultiShell {
out: Shell,
err: Shell,
- verbose: bool
+ verbosity: Verbosity
}
impl MultiShell {
- pub fn new(out: Shell, err: Shell, verbose: bool) -> MultiShell {
- MultiShell { out: out, err: err, verbose: verbose }
+ pub fn new(out: Shell, err: Shell, verbosity: Verbosity) -> MultiShell {
+ MultiShell { out: out, err: err, verbosity: verbosity }
}
pub fn out(&mut self) -> &mut Shell {
}
pub fn say<T: ToString>(&mut self, message: T, color: Color) -> io::Result<()> {
- self.out().say(message, color)
+ match self.verbosity {
+ Quiet => Ok(()),
+ _ => self.out().say(message, color)
+ }
}
pub fn status<T, U>(&mut self, status: T, message: U) -> io::Result<()>
where T: fmt::Display, U: fmt::Display
{
- self.out().say_status(status, message, GREEN)
+ match self.verbosity {
+ Quiet => Ok(()),
+ _ => self.out().say_status(status, message, GREEN)
+ }
}
pub fn verbose<F>(&mut self, mut callback: F) -> io::Result<()>
where F: FnMut(&mut MultiShell) -> io::Result<()>
{
- if self.verbose { return callback(self) }
- Ok(())
+ match self.verbosity {
+ Verbose => return callback(self),
+ _ => Ok(())
+ }
}
pub fn concise<F>(&mut self, mut callback: F) -> io::Result<()>
where F: FnMut(&mut MultiShell) -> io::Result<()>
{
- if !self.verbose { return callback(self) }
- Ok(())
+ match self.verbosity {
+ Verbose => Ok(()),
+ _ => return callback(self)
+ }
}
pub fn error<T: ToString>(&mut self, message: T) -> io::Result<()> {
self.err().say(message, YELLOW)
}
+ pub fn set_verbosity(&mut self, verbose: bool, quiet: bool) -> CargoResult<()> {
+ self.verbosity = match (verbose, quiet) {
+ (true, true) => return Err(human("cannot set both --verbose and --quiet")),
+ (true, false) => Verbose,
+ (false, true) => Quiet,
+ (false, false) => Normal
+ };
+ Ok(())
+ }
+
+ /// shortcut for commands that don't have both --verbose and --quiet
pub fn set_verbose(&mut self, verbose: bool) {
- self.verbose = verbose;
+ if verbose {
+ self.verbosity = Verbose;
+ } else {
+ self.verbosity = Normal;
+ }
}
- pub fn get_verbose(&self) -> bool {
- self.verbose
+ pub fn get_verbose(&self) -> Verbosity {
+ self.verbosity
}
}
pub fn verbose<F>(&mut self, mut callback: F) -> io::Result<()>
where F: FnMut(&mut Shell) -> io::Result<()>
{
- if self.config.verbose { return callback(self) }
- Ok(())
+ match self.config.verbosity {
+ Verbose => return callback(self),
+ _ => Ok(())
+ }
}
pub fn concise<F>(&mut self, mut callback: F) -> io::Result<()>
where F: FnMut(&mut Shell) -> io::Result<()>
{
- if !self.config.verbose { return callback(self) }
- Ok(())
+ match self.config.verbosity {
+ Verbose => Ok(()),
+ _ => return callback(self)
+ }
}
pub fn say<T: ToString>(&mut self, message: T, color: Color) -> io::Result<()> {
- try!(self.reset());
- if color != BLACK { try!(self.fg(color)); }
- try!(write!(self, "{}\n", message.to_string()));
- try!(self.reset());
- try!(self.flush());
- Ok(())
+ match self.config.verbosity {
+ Quiet => Ok(()),
+ _ => {
+ try!(self.reset());
+ if color != BLACK { try!(self.fg(color)); }
+ try!(write!(self, "{}\n", message.to_string()));
+ try!(self.reset());
+ try!(self.flush());
+ Ok(())
+ },
+ }
}
pub fn say_status<T, U>(&mut self, status: T, message: U, color: Color)
use rustc_serialize::json::{self, Json};
use docopt::Docopt;
-use core::{Shell, MultiShell, ShellConfig};
+use core::{Shell, MultiShell, ShellConfig, Verbosity};
+use core::shell::Verbosity::{Verbose};
use term::color::{BLACK, RED};
pub use util::{CargoError, CliError, CliResult, human, Config, ChainError};
{
let mut config = None;
let result = (|| {
- config = Some(try!(Config::new(shell(true))));
+ config = Some(try!(Config::new(shell(Verbose))));
let args: Vec<_> = try!(env::args_os().map(|s| {
s.into_string().map_err(|s| {
human(format!("invalid unicode in argument: {:?}", s))
}).collect());
callback(&args, config.as_ref().unwrap())
})();
- let mut verbose_shell = shell(true);
+ let mut verbose_shell = shell(Verbose);
let mut shell = config.as_ref().map(|s| s.shell());
let shell = shell.as_mut().map(|s| &mut **s).unwrap_or(&mut verbose_shell);
process_executed(result, shell)
}
}
-pub fn shell(verbose: bool) -> MultiShell {
+pub fn shell(verbosity: Verbosity) -> MultiShell {
let tty = isatty(libc::STDERR_FILENO);
let stderr = Box::new(io::stderr());
- let config = ShellConfig { color: true, verbose: verbose, tty: tty };
+ let config = ShellConfig { color: true, verbosity: verbosity, tty: tty };
let err = Shell::create(stderr, config);
let tty = isatty(libc::STDOUT_FILENO);
let stdout = Box::new(io::stdout());
- let config = ShellConfig { color: true, verbose: verbose, tty: tty };
+ let config = ShellConfig { color: true, verbosity: verbosity, tty: tty };
let out = Shell::create(stdout, config);
- return MultiShell::new(out, err, verbose);
+ return MultiShell::new(out, err, verbosity);
#[cfg(unix)]
fn isatty(fd: libc::c_int) -> bool {
let fatal = exit_code != 0; // exit_code == 0 is non-fatal error
- let hide = unknown && !shell.get_verbose();
+ let hide = unknown && shell.get_verbose() != Verbose;
if hide {
let _ = shell.err().say("An unknown error occurred", RED);
} else {
Some(cause) => cause,
None => { err = cargo_err.cause(); break }
};
- if !verbose && !cargo_err.is_human() { return false }
+ if verbose != Verbose && !cargo_err.is_human() { return false }
print(cargo_err.to_string(), shell);
}
loop {
let cause = match err { Some(err) => err, None => return true };
- if !verbose { return false }
+ if verbose != Verbose { return false }
print(cause.to_string(), shell);
err = cause.cause();
}
assert_that(&p.bin("foo"), existing_file());
});
+test!(simple_quiet {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/main.rs", r#"
+ fn main() { println!("hello"); }
+ "#);
+
+ assert_that(p.cargo_process("run").arg("-q"),
+ execs().with_status(0).with_stdout("\
+hello
+")
+ );
+});
+
+test!(simple_quiet_and_verbose {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/main.rs", r#"
+ fn main() { println!("hello"); }
+ "#);
+
+ assert_that(p.cargo_process("run").arg("-q").arg("-v"),
+ execs().with_status(101).with_stderr("\
+cannot set both --verbose and --quiet
+")
+ );
+});
+
test!(simple_with_args {
let p = project("foo")
.file("Cargo.toml", r#"
use term::{Terminal, TerminfoTerminal, color};
use hamcrest::{assert_that};
-use cargo::core::shell::{Shell,ShellConfig};
+use cargo::core::shell::{Shell, ShellConfig};
+use cargo::core::shell::Verbosity::{Verbose, Quiet};
use support::{Tap, shell_writes};
}
test!(non_tty {
- let config = ShellConfig { color: true, verbose: true, tty: false };
+ let config = ShellConfig { color: true, verbosity: Verbose, tty: false };
let a = Arc::new(Mutex::new(Vec::new()));
Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
});
test!(color_explicitly_disabled {
- let config = ShellConfig { color: false, verbose: true, tty: true };
+ let config = ShellConfig { color: false, verbosity: Verbose, tty: true };
let a = Arc::new(Mutex::new(Vec::new()));
Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
let term = TerminfoTerminal::new(Vec::new());
if term.is_none() { return }
- let config = ShellConfig { color: true, verbose: true, tty: true };
+ let config = ShellConfig { color: true, verbosity: Verbose, tty: true };
let a = Arc::new(Mutex::new(Vec::new()));
Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
color::RED).unwrap()));
});
+test!(quiet_shell {
+ let config = ShellConfig { color: true, verbosity: Quiet, tty: true };
+ let a = Arc::new(Mutex::new(Vec::new()));
+
+ Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
+ shell.say("Should be suppressed", color::BLACK).unwrap();
+ });
+
+ let buf = a.lock().unwrap().clone();
+ assert_that(&buf[..],
+ shell_writes(""));
+});
+
fn colored_output(string: &str, color: color::Color) -> io::Result<String> {
let mut term = TerminfoTerminal::new(Vec::new()).unwrap();
try!(term.reset());